<script>
window.addEventListener('beforeunload', event => {
  event.returnValue = 'Leave?';
});
</script>
